------------------------------------------------------------------------------
-- Inventory library for computercraft's turtles by Hea3veN
-- Version 0.1
------------------------------------------------------------------------------
function dropInventoryUp()
	statusSetMsg("Dropping all collected blocks")
		
	while turtle.detectUp() do
		turtle.digUp()
		os.sleep(0.5)
	end
	turtle.select(2)
	turtle.placeUp()
	for i=3,16 do
		turtle.select(i)
		local first = true
		while not turtle.dropUp() do
			if first then
				print("Could not place the items in the chest, waiting for space.")
			end
			os.sleep(1)
		end
	end
	turtle.select(2)
	turtle.digUp()
end

function dropInventoryDown()
	statusSetMsg("Dropping all collected blocks")
		
	while turtle.detectDown() do
		turtle.digDown()
	end
	turtle.select(2)
	turtle.placeDown()
	for i=3,16 do
		turtle.select(i)
		local first = true
		while not turtle.dropDown() do
			if first then
				print("Could not place the items in the chest, waiting for space.")
			end
			os.sleep(1)
		end
	end
	turtle.select(2)
	turtle.digDown()
end

function inventoryDropState()
	turtle.select(2)
	while turtle.detectUp() do
		if not turtle.digUp() then
			return 'end'
		end
		os.sleep(0.5)
	end
	while not turtle.placeUp() do
		turtle.attackUp()
		os.sleep(0.3)
	end
	for i=3,16 do
		turtle.select(i)
		if turtle.getItemCount(i) > 0 then
			local first = true
			while not turtle.dropUp() do
				if first then
					print("Could not place the items in the chest, waiting for space.")
				end
				os.sleep(1)
			end
		end
			
	end
	turtle.select(2)
	turtle.digUp()

	return statusGetProgData().nextState
end
		

function inventoryIsFull()
	for i=3, 16 do
		if turtle.getItemCount(i) == 0 then
			return false
		end
	end
	return true
end
		